home *** CD-ROM | disk | FTP | other *** search
/ MacWorld 2003 August / TommyVideo.iso / flash / menu.swf / scripts / %3Cdefault package%3E / ItemSymbol.as < prev   
Encoding:
Text File  |  2003-06-08  |  3.6 KB  |  118 lines

  1. ItemClass = function()
  2. {
  3.    this.init();
  4. };
  5. ItemClass.prototype = new MovieClip();
  6. ItemClass.prototype.init = function()
  7. {
  8.    this.useHandCursor = false;
  9.    this.txtFormat = new TextFormat();
  10.    this.txtFormat.font = this.parent.txtFont;
  11.    this.txtFormat.size = this.parent.txtSize;
  12.    this.txtFormat.bold = this.txtIsBold;
  13.    this.txtFormat.align = this.txtAlign;
  14.    if(this.isTitle)
  15.    {
  16.       this.beginTxtX = 0;
  17.    }
  18.    else
  19.    {
  20.       this.beginTxtX = 10;
  21.    }
  22.    this.drawItem(0,0,this.menuWidth,this.parent.menuItemHeight,this.bgColor);
  23.    this.drawText(this.beginTxtX,0,this.menuWidth,this.parent.menuItemHeight,this.txtColor,this.txtFormat,this.txtLabel);
  24.    this.tabEnabled = false;
  25. };
  26. ItemClass.prototype.drawText = function(x, y, width, height, textCol, txtFormat, textLabel)
  27. {
  28.    this.createTextField("textfield",1,x,y,width,height);
  29.    this.textfield.autoSize = this.txtAlign;
  30.    this.textField.html = true;
  31.    if(!this.disabled)
  32.    {
  33.       this.textfield.textColor = textCol;
  34.    }
  35.    else
  36.    {
  37.       this.textfield.textColor = this.parent.disabledTextColor;
  38.    }
  39.    this.textfield.text = "" + textLabel;
  40.    this.textfield.selectable = false;
  41.    this.textfield.setTextFormat(txtFormat);
  42.    this.textfield.embedFonts = true;
  43.    this.textfield._y = Math.round((this.parent.menuItemHeight - this.textfield._height) / 2);
  44. };
  45. ItemClass.prototype.drawItem = function(x, y, width, height, fillCol)
  46. {
  47.    this.clear();
  48.    if(this.parent.sepLine || this.firstHoriz)
  49.    {
  50.       this.lineStyle(this.parent.sepLineSize,this.parent.sepLineColor,100);
  51.    }
  52.    this.beginFill(fillCol,100);
  53.    if(fillCol == 1458837)
  54.    {
  55.       this.moveTo(x,y + 1);
  56.       this.lineTo(x + width,y + 1);
  57.       this.lineTo(x + width,y + height);
  58.       this.lineTo(x,y + height);
  59.       this.lineTo(x,y + 1);
  60.       this.endFill();
  61.       this.beginFill(1724600,100);
  62.       this.moveTo(x,y);
  63.       this.lineTo(x + width,y);
  64.       this.lineTo(x + width,y + 1);
  65.       this.lineTo(x,y + 1);
  66.       this.lineTo(x,y);
  67.       this.endFill();
  68.    }
  69.    else
  70.    {
  71.       this.moveTo(x,y);
  72.       this.lineTo(x + width,y);
  73.       this.lineTo(x + width,y + height);
  74.       this.lineTo(x,y + height);
  75.       this.lineTo(x,y);
  76.       this.endFill();
  77.    }
  78.    this.createEmptyMovieClip("menuBorder",20000);
  79.    if(fillCol == 1458837)
  80.    {
  81.       this.menuBorder.lineStyle(0,0,100);
  82.       this.menuBorder.moveTo(x,y + 1);
  83.       this.menuBorder.lineTo(x + width - 1,y + 1);
  84.       this.menuBorder.lineTo(x + width - 1,y + height - 1);
  85.       this.menuBorder.lineTo(x,y + height - 1);
  86.       this.menuBorder.lineTo(x,y + 1);
  87.    }
  88.    if(!this.firstHoriz)
  89.    {
  90.       if(this.hasSubs)
  91.       {
  92.          this.attachMovie("ArrowSymbol","arrow",16000,{_x:Math.round(this.menuWidth) - 10,_y:Math.round((this.parent.menuItemHeight - 7) / 2)});
  93.       }
  94.    }
  95.    if(this.radioGroup != undefined)
  96.    {
  97.       this.attachMovie("RadioButton","RadioButton",17000,{_x:10,_y:Math.round(this.parent.menuItemHeight / 2),_visible:this.active});
  98.    }
  99.    if(this.isCheckBox)
  100.    {
  101.       this.attachMovie("CheckBox","CheckBox",18000,{_x:10,_y:Math.round(this.parent.menuItemHeight / 2),_visible:this.checkBoxIsActive});
  102.    }
  103. };
  104. ItemClass.prototype.setBackgroundColor = function(bgColor)
  105. {
  106.    this.bgColor = bgColor;
  107. };
  108. ItemClass.prototype.setTextColor = function(txtColor)
  109. {
  110.    this.txtColor = txtColor;
  111. };
  112. ItemClass.prototype.update = function()
  113. {
  114.    this.drawItem(0,0,this.menuWidth,this.parent.menuItemHeight,this.bgColor);
  115.    this.drawText(this.beginTxtX,0,this.menuWidth - 20,this.parent.menuItemHeight,this.txtColor,this.txtFormat,this.txtLabel);
  116. };
  117. Object.registerClass("ItemSymbol",ItemClass);
  118.